
var fs=require('fs')
import path from 'path'
function fileDisplay(filePath,app){}
fileDisplay.prototype.setApi=function(filePath,app){
    //根据文件路径读取文件，返回文件列表
   let  from = path.relative(process.cwd(), './server/api');
    // console.log(from);
    let imported = {};
    let joinPath = function () {
        return process.cwd() + path.sep + path.join(...arguments);
    };
    let joinPath2 = function () {
        return '..'+path.sep + path.join(...arguments)+ path.sep;
    };
    let fsPath = joinPath(from);
    let fsPath2 = joinPath2(from);
    fs.readdir(fsPath,function(err,files){
        if(err){
          console.warn(err)
        }else{
            for(let item of files){
                var str=fsPath2+item
                app.use('/v1',require(str))
            }
        }
    })
}
module.exports=fileDisplay;